home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-12-05 | 4.0 KB | 149 lines | [TEXT/PJMM] |
- { TransSkel multiple-window demonstration: main module}
-
- { This module performs setup and termination operations, installs}
- { the window and menu handlers, and processes menu item selections.}
-
- { There are four window handlers in this demonstration. The code}
- { for each handler is in its own module.}
-
- { Help Window Scrollable non-editable text window}
- { Edit Window Non-scrollable editable text window}
- { Zoom Window Non-manipulable graphics display window}
- { Region Window Manipulable graphics display window}
-
- { The project should include RunTime.lib,Interface.lib, TransSkel.p (or a library built}
- { from TransSkel.p), MSkelHelp.p, MSkelEdit.p, MSkelZoom.p and}
- { MSkelRgn.p. You'll also need the MultiSkel.globals.p and common.p header files.}
- { You'll also need to set the resource file to MultiSkel.proj.rsrc.}
-
- { 24 June 1986 Paul DuBois}
- { 8 January 1987 Ported to LightSpeed Pascal by Owen Hartnett }
- { Ωhm Software Company, 163 Richard Drive, Tiverton, RI 02878 }
- { 30 December 1987 OH changed for version 2.00 }
-
- program MultiSkel;
-
- uses
- {$IFC UNDEFINED THINK_PASCAL}
- Memtypes, Quickdraw, OSIntf, ToolIntf, PackIntf,
- {$ENDC}
- MSkelRgn, MultiSkelGlobals, common, TransSkel, MSkelZoom, MSkelEdit, MSkelHelp;
-
- { file menu item numbers }
-
- const
- open = 1;
- close = 2;
- quit = 4;
-
- { Menu handles. There isn't any apple menu here, since TransSkel will}
- { be told to handle it itself.}
-
- var
- filemenu: menuhandle;
-
- { Handle selection of About MultiSkel… item from Apple menu}
-
- procedure DoAbout;
-
- var
- ignore: integer;
- begin
- ignore := Alert(aboutAlrt, nil);
- end;
-
- { Show a window if it's not visible. Select the window FIRST, then}
- { show it, so that it comes up in front. Otherwise it will be drawn}
- { in back then brought to the front, which is ugly.}
-
-
- procedure MyShowWindow (wind: WindowPeek);
- begin
- if (wind^.visible = false) then
- begin
- SelectWindow(WindowPtr(wind));
- ShowWindow(WindowPtr(wind));
- end;
- end;
-
- { Process selection from File menu.}
-
- { Open Make all four windows visible}
- { Close Hide the frontmost window. If it belongs to a desk accessory,}
- { close the accessory.}
- { Quit Request a halt by calling SkelHalt(). This makes SkelMain}
- { return.}
-
- procedure DoFile (item: integer);
-
- var
- wPeek: WindowPeek;
-
- begin
- case item of
- open:
- begin
- MyShowWindow(WindowPeek(rgnWind));
- MyShowWindow(WindowPeek(zoomWind));
- MyShowWindow(WindowPeek(editWind));
- MyShowWindow(WindowPeek(helpWind));
- end;
- close:
-
- { Close the front window. Take into account whether it belongs}
- { to a desk accessory or not.}
-
- begin
- wPeek := WindowPeek(FrontWindow);
- if wPeek <> nil then
- begin
- if (wPeek^.windowKind < 0) then
- CloseDeskAcc(wPeek^.windowKind)
- else
- HideWindow(FrontWindow);
- end;
- end;
- quit:
- SkelWhoa; { request halt }
- end;
- end;
-
- { Process item selected from Edit menu. First check whether it should}
- { get routed to a desk accessory or not. If not, then for route the}
- { selection to the text editing window, as that is the only one for}
- { this application to which edit commands are valid.}
- { (The test of FrontWindow is not strictly necessary, as the Edit}
- { menu is disabled when any of the other windows is frontmost, and so}
- { this Proc couldn't be called.)}
-
- procedure DoEdit (item: integer);
-
- begin
- if not SystemEdit(item - 1) then { check DA edit choice }
- if FrontWindow = editWind then
- EditWindEditMenu(item);
- end;
-
- { Initialize menus. Tell Skel to process the Apple menu automatically,}
- { and associate the proper procedures with the File and Edit menus.}
-
- procedure SetUpMenus;
-
- begin
- SkelApple('About MultiSkel…', @DoAbout);
- fileMenu := GetMenu(fileMenuRes);
- editMenu := GetMenu(editMenuRes);
- dummy := SkelMenu(fileMenu, @DoFile, nil, false);
- dummy := SkelMenu(editMenu, @DoEdit, nil, true);
- end;
-
- begin
- SkelInit(6, nil);
- SetUpMenus; { install menu handlers }
- RgnWindInit; { install window handlers }
- ZoomWindInit;
- EditWindInit;
- HelpWindInit;
- SkelMain;
- SkelClobber; { throw away windows and menus }
- end.